package cn.sytton.taffecloud.common.model.base;

import cn.sytton.taffecloud.common.base.util.SecurityUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.sql.Timestamp;
import java.util.Date;

/**
 * 业务实体类,包括基础的4个基础字段
 *
 * @author skyrock
 */
public class FieldEntity extends BaseEntity {

    /**
     * 创建userId
     */
    @JsonIgnore
    private String createdUserId;
    /**
     * 创建时间
     */
    @JsonIgnore
    private Timestamp createdTime;
    /**
     * 最近一次更新userId
     */
    @JsonIgnore
    private String updatedUserId;
    /**
     * 最近一次更新时间
     */
    @JsonIgnore
    private Timestamp updatedTime;

    public String getCreatedUserId() {
        return createdUserId;
    }

    public void setCreatedUserId(String createdUserId) {
        this.createdUserId = createdUserId;
    }

    public Timestamp getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Timestamp createdTime) {
        this.createdTime = createdTime;
    }

    public String getUpdatedUserId() {
        return updatedUserId;
    }

    public void setUpdatedUserId(String updatedUserId) {
        this.updatedUserId = updatedUserId;
    }

    public Timestamp getUpdatedTime() {
        return updatedTime;
    }

    public void setUpdatedTime(Timestamp updatedTime) {
        this.updatedTime = updatedTime;
    }

    public Timestamp newTimestamp() {
        return new Timestamp(new Date().getTime());
    }

    public void updateField() {
        this.updatedTime = newTimestamp();
        this.updatedUserId = SecurityUtil.getUserId();
    }
}
